      FUNCTION ABSSUV_MPI(array, &
      & i0_arr,i1_arr,j0_arr,j1_arr,k0_arr,k1_arr, &
      & i0,i1,j0,j1,k0,k1,comm3d,parallel)
!-----------------------------------------------------------------------
! abssum=sum of absolute value of array
!
!------------------------------------------------------------------------

!      use MPI
      use MPI_VARIABLES, only : &
      & abssuv_indic
      use TIMING_MOD, only : &
      & proc_time

      implicit none

      include 'mpif.h'


      real(8) :: ABSSUV_MPI

!     Input/output variables
      real(8), intent(in) :: array(i0_arr:i1_arr,j0_arr:j1_arr,k0_arr:k1_arr)
      
      integer(4), intent(in) :: i0, i1
      integer(4), intent(in) :: j0, j1
      integer(4), intent(in) :: k0, k1

      integer(4), intent(in) :: i0_arr, i1_arr
      integer(4), intent(in) :: j0_arr, j1_arr
      integer(4), intent(in) :: k0_arr, k1_arr

      integer(4), intent(in) :: comm3d

      logical, intent(in) :: parallel
     
!     Local variables

      real(8) :: buf
      real(8) :: pr_time, pro_time

      integer(4) :: i, j, k
      integer(4) :: ierr_MPI
      
      buf = 0.d0
      do k = k0, k1
        do j = j0, j1
          do i = i0, i1
            buf = buf + dabs(array(i,j,k))
          enddo
        enddo
      enddo

      if (parallel) then
!        pr_time = MPI_WTIME()
        call cpu_time(pr_time)

        call MPI_ALLREDUCE(buf,ABSSUV_MPI,1,MPI_DOUBLE_PRECISION, &
        & MPI_SUM, comm3d, ierr_MPI)
        
!        proc_time(abssuv_indic,2) = proc_time(abssuv_indic,2) &
!        & + MPI_WTIME() - pr_time

        call cpu_time(pro_time)
        proc_time(abssuv_indic,2) = proc_time(abssuv_indic,2) &
        & + pro_time - pr_time
      else
        ABSSUV_MPI = buf
      endif
      
      return
      END FUNCTION ABSSUV_MPI
